import { axios } from '@/utils/request'
let uri = process.env.NODE_ENV === 'production' ? '' : '' // /api/yb

const api = {
  insertDic: uri + '/system/dictionaries/insertDictionariesInfo',
  updateDic: uri + '/system/dictionaries/updateDictionariesInfo',
  getDicTree: uri + '/system/dictionaries/getDictionariesTree',
  getDicTable: uri + '/system/dictionaries/getDictionariesById',
  deleteDic: uri + '/system/dictionaries/deleteDictionariesInfo',
  updateOrder: uri + '/system/dictionaries/updateOrder'
}

// 数据字典-新增字典列表
export function insertDic(parameter) {
  return axios({
    url: api.insertDic,
    method: 'post',
    data: parameter
  })
}

// 数据字典-修改字典列表
export function updateDic(parameter) {
  return axios({
    url: api.updateDic,
    method: 'put',
    data: parameter
  })
}

// 数据字典-获取字典树
export function getDicTree(id, parameter) {
  return axios({
    url: `${api.getDicTree}/${id}`,
    method: 'get',
    params: parameter
  })
}

// 数据字典-获取字典列表
export function getDicTable(parameter) {
  return axios({
    url: api.getDicTable,
    method: 'get',
    params: parameter
  })
}

// 数据字典-删除字典
export function deleteDic(id, parameter) {
  return axios({
    url: `${api.deleteDic}/${id}`,
    method: 'delete',
    params: parameter
  })
}

export function updateOrder(parameter) {
  return axios({
    url: api.updateOrder,
    method: 'put',
    params: parameter
  })
}
